﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TfsBugger.Util
{
    public static class IEnumerableExtensions
    {
        public static string MapToString<T>(this IEnumerable<T> items, string separator, Func<T, string> mapper)
        {
            StringBuilder sb = new StringBuilder();
            int count = items.Count();
            int i = 0;
            foreach (T t in items)
            {
                sb.Append(mapper(t));
                if (i < count - 1)
                    sb.Append(separator);

                i++;
            }

            return sb.ToString();
        }
    }
}
